package kuzha.runtime;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.script.Bindings;

import kuzha.KuzhaObject;
import kuzha.runtime.jadapter.FromBindingsAdapter;

public class KzBindingsAdapter extends AbstractContext {
	private final Bindings bindings;
	
	public KzBindingsAdapter(Bindings bindings, KuzhaObject _this) {
		super(new FromBindingsAdapter(bindings), _this, null, null);
		if (bindings == null)
			throw new IllegalArgumentException();
		this.bindings = bindings;
	}
	
	// javax.script.Bindings /////////////////////////////////
	
	public void clear() {
		bindings.clear();
	}
	
	public boolean containsKey(Object key) {
		return bindings.containsKey(key);
	}
	
	public boolean containsValue(Object value) {
		return bindings.containsValue(value);
	}

	public Set<Map.Entry<String, Object>> entrySet() {
		return bindings.entrySet();
	}

	public boolean equals(Object o) {
		return bindings.equals(o);
	}

	public Object get(Object key) {
		return bindings.get(key);
	}

	public int hashCode() {
		return bindings.hashCode();
	}

	public boolean isEmpty() {
		return bindings.isEmpty();
	}

	public Set<String> keySet() {
		return bindings.keySet();
	}

	public Object put(String name, Object value) {
		return bindings.put(name, value);
	}

	public void putAll(Map<? extends String, ? extends Object> toMerge) {
		bindings.putAll(toMerge);
	}

	public Object remove(Object key) {
		return bindings.remove(key);
	}

	public int size() {
		return bindings.size();
	}

	public Collection<Object> values() {
		return bindings.values();
	}
}
